<template>
  <div class="structureTree">
    <div class="structureTree_title">
      <div>公司信息</div>
      <div>
        <input
          type="radio"
          name=""
          v-model="radio"
          @click="viewSubordinates()"
        />查看下级
      </div>
    </div>
    <el-tree
      :data="treeData"
      :props="defaultProps"
      @node-click="handleNodeClick"
      node-key="F_CompanyId"
      :accordion="true"
      :expand-on-click-node="false"
      :default-expanded-keys="expandedKeys"
    ></el-tree>
  </div>
</template>

<script>
export default {
  data() {
    return {
      radio: "true",
      treeData: [
        {
          label: "一级 1",
          children: [
            {
              label: "二级 1-1",
              children: [
                {
                  label: "三级 1-1-1",
                },
              ],
            },
          ],
        },
        {
          label: "一级 2",
          children: [
            {
              label: "二级 2-1",
              children: [
                {
                  label: "三级 2-1-1",
                },
              ],
            },
            {
              label: "二级 2-2",
              children: [
                {
                  label: "三级 2-2-1",
                },
              ],
            },
          ],
        },
        {
          label: "一级 3",
          children: [
            {
              label: "二级 3-1",
              children: [
                {
                  label: "三级 3-1-1",
                },
              ],
            },
            {
              label: "二级 3-2",
              children: [
                {
                  label: "三级 3-2-1",
                },
              ],
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "f_ShortName",
      },
    };
  },
  mounted() {
    this.getTree();
  },
  methods: {
    viewSubordinates() {
      this.radio = !this.radio;
    },
    handleNodeClick(data) {
      console.log(data);
    },
    // 页面获取存在本地的值
    getTree() {
      // console.log(sessionStorage.getItem("monitorBack-companyTree"));
      var data = window.sessionStorage.getItem("monitorBack-companyTree");
      this.treeData = JSON.parse(data);
    },
  },
};
</script>
<style scoped>
</style>